//
//  HWGameLiveChatEnterRoomCell.swift
//  PlayWithProject
//
//  Created by 王昌健 on 2021/10/27.
//

import UIKit

class HWGameLiveChatEnterRoomCell: UITableViewCell {
    var bgView:UIView!
    var titleLabel:UILabel!
    var contentLabel:UILabel!
    var model:HWGameLiveChatModel?{
        didSet{
            titleLabel.text = model?.userName
        }
    }
    class func cellWithTableView(tableView:UITableView) -> (HWGameLiveChatEnterRoomCell) {
        let reUse:String = "HWGameLiveChatEnterRoomCell"
        
        var cell = tableView.dequeueReusableCell(withIdentifier: reUse)
        
        if cell == nil {
            cell = HWGameLiveChatEnterRoomCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: reUse)
        }
        
        return cell as! HWGameLiveChatEnterRoomCell
    }
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        initUI()
        initFrame()
    }
    
    func initUI() -> Void {
        selectionStyle = UITableViewCell.SelectionStyle.none
        backgroundColor = UIColor.clear
        
        bgView = UIView()
        bgView.backgroundColor = .colorWithHexString(hexString: "#FCF7FF")
        contentView.addSubview(bgView)
        
        titleLabel = HWLabel.createLabel(title: "xxxx", color: "#8D9AB1", font: 12*widthScale)
        bgView.addSubview(titleLabel)
        
        contentLabel = HWLabel.createLabel(title: "进入直播间", color: "#666666", font: 12*widthScale)
        bgView.addSubview(contentLabel)
    }
    
    func initFrame() -> Void {
        bgView.snp.makeConstraints { make in
            make.left.right.equalTo(0)
            make.top.equalTo(5*widthScale)
            make.bottom.equalTo(-5*widthScale)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(21*widthScale)
        }
        
        contentLabel.snp.makeConstraints { make in
            make.left.equalTo(titleLabel.snp.right).offset(5*widthScale)
            make.right.equalTo(-21*widthScale)
            make.centerY.equalTo(titleLabel)
            make.top.equalTo(5*widthScale)
            make.bottom.equalTo(-5*widthScale)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
